package me.send.data.service.mapper;

import java.util.List;

import me.send.data.service.pojo.Commaddress;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public abstract interface CommaddressMapper {

	// 保存常用地址 2015年6月1日17:30:33
	@Insert(value = "insert into commaddress(text,telephone,createtime,name,userid) values(#{text},#{telephone},#{createtime},#{name},#{userid})")
	@Options(keyProperty="addressid",useGeneratedKeys=true)
	public abstract void save(Commaddress commaddress);

	// 方便 下面的列表 2015年6月1日17:36:46
	@Select(value = "select * from commaddress c where userid = #{userid} and isdetete=0 order by addressid DESC")
	public abstract List<Commaddress> list_userid(int userid);

	// 编辑下面的常用地址 2015年6月1日17:38:43
	@Update(value = "update commaddress set text = #{text},telephone=#{telephone},name=#{name},updatetime=#{updatetime} where userid = #{userid} AND addressid=#{addressid}")
	public abstract void update_userid(Commaddress commaddress);

	@Delete(value = "delete from commaddress where addressid = #{addressid}")
	public abstract void delete_id(int addressid);

	
	@Select(value = "select * from commaddress c where addressid = #{id} LIMIT 1")
	abstract Commaddress getCommAddressById(Integer id);
}
